jQuery(document)
        .ready(
                function($) {
                    /* PANEL DETAIL LOTE LANCES */

                    $.fn.lancesOperationsInitialize();

                    //return;
                   atualizeLancesPainel(url_site + 'ping-lances.html');

                    $('.jqzoom').jqzoom({
                        zoomType: 'innerzoom',
                        lens: true,
                        preloadImages: false,
                        alwaysOn: false
                    });

                    $('.text-link-video').fancybox({
                        openEffect: 'none',
                        closeEffect: 'none',
                        prevEffect: 'none',
                        nextEffect: 'none',
                        arrows: false,
                        helpers: {
                            media: {},
                            buttons: {}
                        }
                    });

                    function ionExpiresCount(element) {
                        var id = $(element).attr('data-id'), lote = $(element)
                                .attr('data-lt-id'), leilao = $(element).attr(
                                'data-le-id'), ativo = $(element).attr(
                                'data-at-id'), markup = '<div class="box-encerrado"></div>'
                                + '<div class="text-encerrado"><span class="glyphicon glyphicon-ban-circle"></span> Encerrado</div>';
                        var idata = {
                            lote: lote,
                            ativo: ativo,
                            leilao: leilao
                        };
                        $.ajax({
                            url: url_site + 'lote-on-close.html',
                            dataType: 'json',
                            type: 'post',
                            data: idata,
                            success: function(data) {

                                location.reload();
                            }
                        });

                    }

                    function applyCountData(obj) {

                        var data = $(this).attr('data-count'), data = data
                                .split(' '), ar_date = data['0'].split('-'), ar_hour = data['1']
                                .split(':'), untilDate = new Date(ar_date['0'],
                                ar_date['1'] - 1, ar_date['2'], ar_hour['0'],
                                ar_hour['1'], ar_hour['2']);
                        // return false;
                        $(this).countdown({
                            until: untilDate,
                            layout: '{dn} {hn} {mn} {sn}',
                            onTick: ionTickerCountDown,
                            onExpiry: ionExpiresCount,
                            tickInterval: 1
                        });
                    }
                    isSeconds = 1;
                    function updateTime() {
                        $.ajax({
                            url: url_site + 'home/updatehashTime',
                            type: 'post',
                            dataType: 'json',
                            data: {
                                id: ids,
                                time: '2013-11-28 03:02:30'
                            },
                            success: function(data) {
                                console.log(data);
                                if (data.full_seconds < 0) {
                                    isSeconds = 0;
                                    clearTimeout(isUpdate);
                                }
                            }
                        });
                        if (isSeconds > 0) {
                            isUpdate = setTimeout(updateTime, 1000);
                        }
                    }

                    function ajaxRefreshHistory() {
                        $('.box-atualize-history').each(function() {
                            var id = $(this).attr('lote-id'), obj = this;
                            $.ajax({
                                url: '/home/getHistoryLote/' + id,
                                success: function(html) {
                                    $(obj).html(html);
                                    // $('.box-atualize-history').html;
                                }
                            });
                        });
                    }

                    function renderCountHtml(obj, periods) {

                        $(obj).html(
                                '<div>' + periods.days + ' ' + periods.hours
                                + ':' + periods.minutes + ':'
                                + periods.seconds + '</div>');
                    }

                    ajaxRefreshHistory();
                    setInterval(ajaxRefreshHistory, 15000);
                    // updateTicker();
                    /*
                     $('.clock-count-ativo-single')
                     .onTickerTime(
                     {
                     triggerdate: 'data-count',
                     tickerInterval: 0.3,
                     DisplayFormat: "%%D%%D %%H%%:%%M%%:%%S%%",
                     finish: function(element) {
                     var id = $(element).attr(
                     'data-lt-id');
                     $(
                     '.dar-lance[data-lt-id="'
                     + id + '"]')
                     .remove();
                     ionExpiresCount(element);
                     },
                     update: function(element, secs) {
                     var id = $(element).attr(
                     'data-lt-id'), tickers = $.onTickerleilao.tickers, dafault_date = $(
                     element).data('TargetDate'), tkstamp = $.onTickerleilao.tickers_stamp;
                     
                     if ((tickers.length > 0
                     && tickers[id] !== dafault_date && tickers[id] !== false)) {
                     $(element).data('TargetDate',
                     tickers[id]);
                     }
                     onTicker['data-' + id] = secs;
                     }
                     });
                     // updateTime();
                     
                     $('a[role="lanceMinimo"]').on('click.LMinimo', function(e) {
                     e.preventDefault();
                     
                     $('[data-multiply="1"]').trigger('click');
                     $('a[role="addNewLance"]').trigger('click');
                     
                     });*/
});
